package com.yeu;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class AjaxTest
 */
@WebServlet("/AjaxTest")
public class AjaxTest extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AjaxTest() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8"); // 设置响应报文的编码格式
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		PrintWriter pWriter = response.getWriter();
		pWriter.println("<br/>");
		pWriter.println("<font size='5' color='red'>浪子心声</font><br/>");
		pWriter.println("<font size='2'>刘德华</font><br/><br>");
		pWriter.println("难分真与假，人面多险诈<br/>");
		pWriter.println("中国最好！");
		pWriter.flush();
		System.out.println("AjaxTest.doGet()");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8"); // 设置响应报文的编码格式
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		
		PrintWriter pWriter = response.getWriter();
		pWriter.println("<br/>");
		pWriter.println("<font size='5' color='red'>浪子心声</font><br/>");
		pWriter.println("<font size='2'>刘德华</font><br/><br>");
		pWriter.println("难分真与假，人面多险诈<br/>");
		pWriter.println(request.getParameter("number"));
		pWriter.println(request.getParameter("password"));
		
		pWriter.flush();
		System.out.println("AjaxTest.doGet()");
	}

}
